package com.tnsw.noxnox;
import java.util.Set;

import dalvik.system.DexClassLoader;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;


public class MyBroadcastReceiver extends BroadcastReceiver {

	private String tag = "MyBroadcastReceiver";
	
	public MyBroadcastReceiver() {
		Log.d(tag, "Constructor()");
	}
	
	@Override
	public void onReceive(Context context, Intent intent) {
		Log.d(tag, "onReceive()");
		Log.d(tag, "intent.getAction()=" + intent.getAction());		
		
		Bundle b = intent.getExtras();
		
		Set<String> set = b.keySet();
		for (String s : set) {
			Log.d(tag, "key=" + s + ", values=" + b.getString(s));
		}
		
		if (GCMIntentService.sIsRunning == false) {
		
			Log.d(tag, "isRunning==false");
			intent.setClassName(context, GCMIntentService.class.getName());
			context.startService(intent);
			
			//Intent i2 = new Intent(context, GCMIntentService.class);
			//context.startService(i2);
			Log.d(tag, "I think it started");
			
			//GCMIntentService gcm = GCMIntentService.getInstance();
			//gcm.doHandle(intent);
			
		} else {
			GCMIntentService gcm = GCMIntentService.getInstance();
			gcm.doHandle(intent);
		}
		
		
		
	}

}
